#include <stdio.h>

int main(){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    a--;
    b--;
    int* input=new int[n];
    int* queue=new int[n];
    int* result=new int[n];
    int i,j;
    for(i=0;i<n;i++)
    {
        scanf("%d",&input[i]);
        result[i]=-1;
    }

    result[a]=0;
    int start=0;
    int end=1;
    //入队开始BFS
    queue[0]=a;
    while (start<end)
    {
        i=queue[start];
        j=i+input[i];
        if(j<n&&result[j]<0)
        {
            result[j]=result[i]+1;
            queue[end]=j;
            end++;
        }

        j=i-input[i];
        if(j>=0&&result[j]<0)
        {
            result[j]=result[i]+1;
            queue[end]=j;
            end++;
        }
        start++;
    }

    printf("%d\n",result[b]);
    
    delete input;
    delete queue;
    delete result;

    
    
    
    return 0;
}